package com.chuanye.jiguangimdemo.activitys;

import androidx.appcompat.app.AppCompatActivity;

import android.content.Context;
import android.os.Bundle;
import android.text.TextUtils;
import android.util.Log;
import android.view.View;
import android.widget.ImageView;
import android.widget.TextView;

import com.chuanye.jiguangimdemo.R;

import cn.jpush.im.android.api.JMessageClient;
import cn.jpush.im.android.api.model.UserInfo;

public class PersonalActivity extends BaseActivity implements View.OnClickListener {
    private static final String TAG = "PersonalActivity";
    private Context mContext;
    private ImageView personal_back_iv;
    private ImageView personal_icon_iv;
    private TextView personal_username_tv;
    private TextView personal_qita_tv;


    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_personal);
        mContext = this;

        initView();
    }

    private void initView() {
        //返回
        personal_back_iv = findViewById(R.id.personal_back_iv);
        personal_back_iv.setOnClickListener(this);
        //头像
        personal_icon_iv = findViewById(R.id.personal_icon_iv);

        //用户名
        personal_username_tv = findViewById(R.id.personal_username_tv);
        //其它
        personal_qita_tv = findViewById(R.id.personal_qita_tv);

        //获取当前登录账号的用户信息
        //此接口会直接从本地返回当前已经登录的用户的信息。
        UserInfo userInfo = JMessageClient.getMyInfo();
        Log.i(TAG,"获取用户信息：用户名："+userInfo.getUserName()+" ,别名："+userInfo.getNickname());

        //用户名
        if (!TextUtils.isEmpty(userInfo.getUserName())){
            personal_username_tv.setText(userInfo.getUserName());
        }

    }

    @Override
    public void onClick(View v) {
        switch (v.getId()){
            case R.id.personal_back_iv://返回
                finish();
                break;
        }
    }
}
